/*
 * @lc app=leetcode.cn id=1720 lang=typescript
 *
 * [1720] 解码异或后的数组
 */

// @lc code=start
// TODO 异或的逆运算
function decode(encoded: number[], first: number): number[] {
    let last = first;

    return [
        first,
        ...encoded.map((i) => {
            const result = last ^ i;
            last = result;
            return result;
        }),
    ];
}
// @lc code=end
